package io.renren.modules.task.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.task.entity.MtCcEquipmentRunInfoEntity;
import io.renren.modules.task.model.MtCcEquipmentRunInfoEntityVo;
import io.renren.modules.task.service.MtCcEquipmentRunInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-04-23 09:03:44
 */
@RestController
@Api(description = "任务操作API")
@RequestMapping("generator/mtccequipmentruninfo")
public class MtCcEquipmentRunInfoController {
    @Autowired
    private MtCcEquipmentRunInfoService mtCcEquipmentRunInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = mtCcEquipmentRunInfoService.queryPage(params);
        return R.ok().put("page", page);
    }

    /**
     * 列表
     */
    @RequestMapping("/list/one")
    public R listOne(@RequestParam Map<String, Object> params){
        PageUtils page = mtCcEquipmentRunInfoService.listOne(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		MtCcEquipmentRunInfoEntity mtCcEquipmentRunInfo = mtCcEquipmentRunInfoService.getById(id);

        return R.ok().put("mtCcEquipmentRunInfo", mtCcEquipmentRunInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody MtCcEquipmentRunInfoEntity mtCcEquipmentRunInfo){
		mtCcEquipmentRunInfoService.save(mtCcEquipmentRunInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody MtCcEquipmentRunInfoEntity mtCcEquipmentRunInfo){
		mtCcEquipmentRunInfoService.updateById(mtCcEquipmentRunInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		mtCcEquipmentRunInfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     * 显示放料台的任务信息L
     */
    @GetMapping("/select/list/one")
    @ApiOperation(value = "显示放料台信息" , notes = "显示放料台信息")
    public R selectListOne(@RequestParam Map<String, Object> params){
//        Map<String,Object> params = new HashMap<>();
//        params.put("taskType",0);
//        params.put("status",0);
        PageUtils page = mtCcEquipmentRunInfoService.selectListOne(params);
        return R.ok().put("page", page);
    }

    /**
     * 展示货区
     */
    @PostMapping("/show/ware")
    @ApiOperation(value = "展示货区" , notes = "展示货区")
    public R showWare(@RequestBody Map<String, Object> params){
        List<MtCcEquipmentRunInfoEntityVo> list = mtCcEquipmentRunInfoService.showWare(params);
        return R.ok().put("page",list);
    }

}
